<cfoutput>
	<cfif IsUserLoggedIn() and IsDefined("request.scholar") and request.scholar.Scholarship_ID gt 0>
		<cfscript>
			scholarshipGateway = new assets.calgrants.com.gateway.ScholarshipGateway();
			scholarship = scholarshipGateway.get(Scholarship_ID = GetAuthUser());
			releaseType = IIf(DateDiff("yyyy", scholarship.getDOB(), Now()) lte 18, DE("parent"), DE("scholar"));
		</cfscript>
		<script type="text/javascript" language="javascript">
		<!--
				var releaseType = "#releaseType#";
				var cohort = "#scholarship.getCohort()#";
				var scholarshipType = "#Lcase(scholarship.getScholarship_Type())#";
				var scholarSignature = "#Trim(scholarship.getFirst_Name())# #Trim(scholarship.getLast_Name())#";
			
			var validate = function() {
				var errors = "";
				var valid = true;
				//console.log($("##authorizedYes").is(":checked"));
				if ((cohort == "5" && scholarshipType == "performance based scholarship") || cohort === "7") {
					if (!$("##authorizedYes").is(":checked") && !$("##authorizedNo").is(":checked") && !$("##authorizedBlank").is(":checked")) {
						valid = false;
						errors += "Release Approval is required\n";
					} else if ($("##authorizedNo").is(":checked")) {
						valid = false;
						if (releaseType == "scholar") {
							errors += "To receive this scholarship you must approve and sign the release\n";
						} else if (releaseType == "parent") {
							errors += "To receive this scholarship your parent or legal guardian must approve and sign this release\n";
						}
					} else if ($("##authorizedYes").is(":checked") && $("##Authorized_Signature").val().length == 0) {
						valid = false;
						errors += "eSignature is required\n";
					} else if (releaseType == "scholar" && $("##Authorized_Signature").val() !== scholarSignature) {
						valid = false;
						errors += "eSignature must be spelled exactly the same as\: " + scholarSignature + "\n";
					} else if ($("##authorizedBlank").is(":checked") && $("##Authorized_Signature").val().length > 0) {
						valid = false;
						errors += 'You selected \"My parent or legal guardian will sign later\" but also signed the release\n';
					}
				} else if (!$("##authorizedYes").is(":checked") && !$("##authorizedNo").is(":checked")) {
					valid = false;
					errors += "Release Approval is required\n";
				}
				if (!$("##volunteerYes").is(":checked") && !$("##volunteerNo").is(":checked")) {
					valid = false;
					errors += '\"May we contact you to help high school seniors apply next year\?\" is required\n';
				}
				if (!valid) {
					alert(errors);
				}
				return valid;				
			}
		//-->
		</script>
		<!--- if (!$("#authorizedYes").is(":checked") && !$("#authorizedNo").is(":checked") && !$("#authorizedBlank").is(":checked")) {
			valid = false;
			errors += "A selection for Release Approval is required";
		} else {
			if ($(".Authorized").val() == "0") {
				valid = false;
				errors += "To receive this scholarship you must approve this release.\n\nYour information will be kept private - we do not share data with unauthorized organizations. Your data is used to evaluate and improve the scholarship program.\n\nTo continue please approve and sign the release.";
			}
			if ($(".Authorized").val() == "1" && $("#Authorized_Signature").val().length == 0) {
				valid = false;
				errors += "eSignature is required";
			}
		} --->
		<cfform name="scholarAuthorizationForm" id="scholarAuthorizationForm" action="#script_name#" method="post" onsubmit="return validate();">
			<cfinput type="hidden" name="action" value="saveScholar" />
			<cfinput type="hidden" name="Scholarship_ID" value="#GetAuthUser()#" />
			<cfif IsDate(request.scholar.Claim_Date)>
				<cfinput type="hidden" name="view" value="#view#" />
			<cfelse>
				<cfinput type="hidden" name="view" value="scholarClaimed" />
			</cfif>
			<div class="row">
				<div class="span12">
					<div class="well" style="margin-right: 20px;">
						<p><strong>Release of Confidential Information to Authorized Persons/Organizations</strong></p>
						<cfif (scholarship.getCohort() eq 5 and scholarship.getScholarship_Type() neq "ccfc") OR scholarship.getCohort() eq 7>
							<p>By signing and submitting this form, I authorize California Cash for College to share all information held by California Cash for College relating to me, including all information I provide in my application including, but not limited to, personal information, such as my name, mailing address, email address and date of birth, and information relating to any financial aid awarded to me and my attendance at any higher education institution (together, my "Personal Information"), with the College Futures Foundation ("CFF") for the purpose of researching and evaluating scholarships and programs, and to better enable young people to attend college and university.</p>
							<p>I further authorize CFF to share my Personal Information (including my name and birth date) with the National Student Clearinghouse in order to verify my enrollment in and attendance at any higher education program to which I am admitted. I also authorize CFF to share relevant portions of my Personal Information with (i) governmental agencies responsible for administering public financial aid programs, including the California Student Aid Commission, so that CFF can obtain information on financial aid I receive or to which I may be entitled, (ii) any higher education institution to which I am admitted so that CFF can verify my enrollment and obtain information on my academic progress (including transcripts), (iii) CFF's third party service providers, such as CFF's or California Cash for College's data management system provider, (iv) research institutions which undertake research on strategies to increase access to and successful completion of higher education programs, where transcripts and similar information are analyzed by such research institutions so that CFF can obtain information on my academic progress towards a degree or transfer to a four-year degree awarding institution, and (v) any other administrative, law enforcement or governmental agencies to the extent required by order or requirement of a court or such administrative, law enforcement or governmental agency.</p>
							<p>CFF monitors the progress of students who receive scholarships funded by it and students served by its grantees and partner organizations so that CFF can better evaluate the effectiveness of these scholarships and other sources of financial aid in light of its charitable mission. As part of the monitoring process, CFF may share aggregated information that does not include my Personal Information and may otherwise disclose non-identifying information with third parties for analysis, demographic profiling and other purposes. Any aggregated information shared in these contexts will not contain my Personal Information. I understand that CFF will take appropriate steps designed to secure and protect the information I provide, to keep it confidential, and to prevent others from connecting this data to me. To the extent possible, except as set forth in this form, any information that could identify me will be removed or changed before such information is shared with other researchers, organizations, or institutions and before any research results are made public in an aggregated form. Except as set forth in this form, under no circumstances will my identity and Personal Information be revealed by CFF.</p>
							<p>This authorization will remain in effect until I revoke it, which I may do at any time by contacting California Cash for College at <a href="mailto:cashforcollege@csac.ca.gov">cashforcollege@csac.ca.gov</a>. Any waiver, modification or amendment of this form will be effective only if acknowledged in by CFF. Further, I understand that California Cash for College will maintain a record of this form, that I am entitled to request and receive a copy, and that I may wish to make a copy of this form for my own records.</p>
							<p>This form will be governed by and construed in accordance with the laws of the State of California, excluding that body of law known as conflict of laws. If any provision of this form is found to be invalid or unenforceable, that provision will be enforced to the maximum extent permissible and the other provisions will remain in full force and effect. Failure to enforce any provision of the form will not constitute a waiver of future enforcement of that or any other provision. This form may be executed in counterparts, each of which will be deemed an original, but all of which together will constitute one and the same instrument.</p>
						<cfelse>
							<p>We would like to evaluate our programs to better enable students to attend college. With your approval, may we share your information with the National Student Clearinghouse solely to verify your enrollment in the college or university to which you are admitted.</p>
						</cfif>
					</div>
					<blockquote>
						<div class="text-control clearfix">
							<label class="required">Release Approval</label>		
							<label class="radio">
								<cfinput type="radio" id="authorizedYes" name="Authorized" value="1" checked="yes"> Yes, I approve
							</label>
							<label class="radio">
								<cfif scholarship.getAuthorized() eq 0>
									<cfinput type="radio" id="authorizedNo" name="Authorized" value="0" checked="yes"> No, I do not approve
								<cfelse>
									<cfinput type="radio" id="authorizedNo" name="Authorized" value="0"> No, I do not approve
								</cfif> 
							</label>
							<cfif ((scholarship.getCohort() eq 5 and scholarship.getScholarship_Type() eq "performance based scholarship") OR scholarship.getCohort() eq 7) AND releaseType eq "parent">
								<label class="radio">
									<cfinput type="radio" id="authorizedBlank" name="Authorized" value="0" checked="yes"> My parent or legal guardian will sign later
								</label>
							</cfif>
						</div>
						<cfif (scholarship.getCohort() eq 5 and scholarship.getScholarship_Type() eq "performance based scholarship") or scholarship.getCohort() eq 7>
							<!--- student signature --->
							<cfif releaseType eq "scholar">
								<cfinput type="hidden" name="Authorized_By" value="Student">
								<div class="clearfix">
									<label class="required">eSignature</label>
									<cfinput type="text" name="Authorized_Signature" value="#scholarship.getAuthorized_Signature()#" maxlength="200" style="width: 350px;">
									<span class="help-block">This release must be signed by <strong>#scholarship.getFirst_Name()# #scholarship.getLast_Name()#</strong>.</span>
								</div>
							<!--- parent signature --->
							<cfelseif releaseType eq "parent">
								<cfinput type="hidden" name="Authorized_By" value="Parent">
								<div class="clearfix">
									<label class="required">eSignature of parent or legal guardian</label>
									<cfinput type="text" name="Authorized_Signature" value="#scholarship.getAuthorized_Signature()#" maxlength="200" style="width: 350px;">
									<span class="help-block">This release must be signed by the <strong>parent or legal gaurdian</strong> of #scholarship.getFirst_Name()# #scholarship.getLast_Name()#.</span>
								</div>
							</cfif>
						</cfif>
					</blockquote>
					<div class="well" style="margin-right: 20px;">
						<p><strong>Want to Help?</strong></p>
						<p>We invite you to join us next year helping high school seniors apply for financial aid. You've been through the process, you know how it works!</p>
					</div>
					<blockquote>
						<div class="text-control clearfix">
							<label class="required">May we contact you to help high school seniors apply next year?</label>
							<label class="radio">
								<cfinput type="radio" id="volunteerYes" name="Volunteer" value="1" checked="yes"> Yes, I want to help
							</label>
							<label class="radio">
								<cfif scholarship.getVolunteer() eq 0>
									<cfinput type="radio" id="volunteerNo" name="Volunteer" value="0" checked="yes"> No
								<cfelse>
									<cfinput type="radio" id="volunteerNo" name="Volunteer" value="0"> No
								</cfif> 
							</label>
						</div>
					</blockquote>
				</div>
			</div>
			<div class="row">
				<div class="span12">
					<div style="margin-bottom: 20px;">
						<cfif GetUserRoles() eq "scholar">
							<cfinput type="submit" name="saveButton" class="btn btn-primary" value="Save" />
						<cfelse>
							<a href="?view=editScholarBanking" class="btn btn-primary">Back</a>
							<button type="submit" name="continueButton" class="btn btn-primary">Continue</button>
						</cfif>
					</div>
				</div>
			</div>
		</cfform>
	<cfelse>
		<div class="row">
			<div class="span12">
				<div class="alert alert-info notFound">Scholarship not found</div>
			</div>
		</div>
	</cfif>
</cfoutput>